"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var menu_1 = require("./menu");
var local_storage_service_1 = require("../lib/service/local-storage.service");
var api_1 = require("../../config/api");
var display_service_1 = require("./display/display.service");
var MemberComponent = /** @class */ (function () {
    function MemberComponent(localStorageService, route, displayService, router) {
        this.localStorageService = localStorageService;
        this.route = route;
        this.displayService = displayService;
        this.router = router;
        this.head_img = '';
        this.hadLoginName = '';
        this.menu = menu_1.MENU;
        this.isCollapsed = false;
        this.AliyunOssOutputUrl = api_1.AliyunOssOutputUrl;
        this.dropShow = false;
        this.addRouteUrl = '';
        this.timer = null;
    }
    MemberComponent.prototype.hidedrop = function () {
        var _this = this;
        console.log('mnmn');
        clearTimeout(this.timer);
        this.timer = setTimeout(function () {
            _this.dropShow = false;
        }, 1000);
    };
    MemberComponent.prototype.opendrop = function () {
        clearTimeout(this.timer);
        this.dropShow = true;
    };
    MemberComponent.prototype.clear = function () {
        this.localStorageService.clearAll();
        location.href = '/';
    };
    MemberComponent.prototype.changeCol = function () {
        this.isCollapsed = !this.isCollapsed;
    };
    MemberComponent.prototype.ngOnInit = function () {
        var _this = this;
        this.head_img = this.localStorageService.getUserInfo().avatar;
        this.hadLoginName = this.localStorageService.getUserInfo().nick_name;
        this.menu.forEach(function (item) {
            var href = window.location.href;
            if (item.path && href.indexOf(item.path) >= 0) {
                item.expanded = true;
            }
            else if (item.children && _this.getExpanded(item.children, href)) {
                item.expanded = true;
            }
            else {
                item.expanded = false;
            }
        });
    };
    MemberComponent.prototype.ngDoCheck = function () {
        if (!this.addRouteUrl) {
            this.addRouteUrl = localStorage.getItem('addRouteUrl');
        }
        this.activePath = location.pathname.substr(0, 15);
    };
    MemberComponent.prototype.clearActive = function (path) {
        if (path == '/member/display') {
            this.displayService.id = -999;
        }
    };
    MemberComponent.prototype.getExpanded = function (list, href) {
        var _this = this;
        var result = false;
        list.forEach(function (item) {
            if (item.path && href.indexOf(item.path) >= 0) {
                result = true;
            }
            else if (item.children) {
                if (_this.getExpanded(item.children, href)) {
                    result = true;
                }
            }
        });
        return result;
    };
    MemberComponent.prototype.expandChange = function (operateStatus, index) {
        if (operateStatus) {
            this.menu.every(function (val, idx, array) {
                if (index !== idx) {
                    val.expanded = false;
                }
                return true;
            });
        }
    };
    MemberComponent = __decorate([
        core_1.Component({
            selector: 'app-member',
            templateUrl: './member.component.html',
            styleUrls: ['./member.component.scss'],
            providers: [
                local_storage_service_1.LocalStorageService, display_service_1.DisplayService
            ]
        })
    ], MemberComponent);
    return MemberComponent;
}());
exports.MemberComponent = MemberComponent;
